/* Dump or view gcc tree.


   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */ 

#include "gml4gtk-plugin.h"

/* Dump tree node NODE into the file FNAME.  */

static void
dump_tree_node_to_file (char *fname, tree node)
{
  g_graph *graph;

  graph = dot_plugin_common.top_graph;

  dot_plugin_common.dump (fname);

  return;
}

/* Dump tree NODE into the file FNAME.  */

static void
dump_tree_to_file (char *fname, tree node)
{
  g_graph *graph;

  graph = dot_plugin_common.top_graph;

  dot_plugin_common.dump (fname);

  return;
}

/* Public function to dump a gcc tree NODE.  */

void
dot_plugin_dump_tree_node (tree node)
{
  dot_plugin_common.init ();

  dump_tree_node_to_file ("dump-tree-node.dot", node);

  dot_plugin_common.finish ();

  return;
}

/* Public function to view a gcc tree NODE.  */

void
dot_plugin_view_tree_node (tree node)
{
  dot_plugin_common.init ();

  dump_tree_node_to_file (dot_plugin_common.temp_file_name, node);
  dot_plugin_common.show (dot_plugin_common.temp_file_name);

  dot_plugin_common.finish ();

  return;
}

/* Public function to dump a gcc tree NODE.  */

void
dot_plugin_dump_tree (tree node)
{
  dot_plugin_common.init ();

  dump_tree_to_file ("dump-tree.dot", node);

  dot_plugin_common.finish ();

  return;
}

/* Public function to view a gcc tree NODE.  */

void
dot_plugin_view_tree (tree node)
{
  dot_plugin_common.init ();

  dump_tree_to_file (dot_plugin_common.temp_file_name, node);
  dot_plugin_common.show (dot_plugin_common.temp_file_name);

  dot_plugin_common.finish ();

  return;
}

/* end */
